<include file="Public:header" />
<div class="subnav">
  <div class="explain-col" style="position: relative;">
    <form name="searchForm" id="searchForm" method="GET" action="__ACTION__" onsubmit="return checkForm()">
      统计分析：
      <select name="searchType" id="searchType"  >
            <option value="1" selected="selected">本月</option>
            <option value="2" <eq name="Think.get.searchType" value="2"> selected="selected"</eq> />上月</option>
            <option value="3" <eq name="Think.get.searchType" value="3"> selected="selected"</eq> />本周</option>
            <option value="4" <eq name="Think.get.searchType" value="4"> selected="selected"</eq> />上周</option>
            <option value="5" <eq name="Think.get.searchType" value="5"> selected="selected"</eq> />今天</option>
            <option value="6" <eq name="Think.get.searchType" value="6"> selected="selected"</eq> />昨天</option>
            <option value="10" <eq name="Think.get.searchType" value="10"> selected="selected"</eq> />自定</option>
      </select>
      <span id="searchTime" style="display:none;">
      从：<input type="text" class="input-text Wdate" size="20" name="startTime" id="startTime" value="{$Think.get.startTime|default=time()|date='Y-m-d',###}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      到&nbsp;<input type="text" class="input-text Wdate" size="20" name="endTime" id="endTime" value="{$Think.get.endTime|default=time()|date='Y-m-d H:i:s',###}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="readonly" />
      </span>

      <eq name="showUserStatistics" value="1">
      <!-- <select name="userId" id="userId" onchange="searchForm.submit();" >
            <option value="0" selected="selected">请选择用户</option>
            <volist name="userList" id="vo">
            <option value="{$vo.id}" <eq name="Think.get.userId" value="$vo.id"> selected="selected"</eq> />{$vo.username}</option>
            </volist>
      </select> -->
      </eq>
      <input type="submit" value=" 搜索 " class="button" />
    </form>
      <div class="content-menu" style="position: absolute; right: 30px;top: 5px;">
        <a href="javascript:openWinBox('__URL__/statisticsColumn/year/{$Think.get.year}/month/{$Think.get.month}','柱型图',980,600)" class="add fb" ><em>统计图</em></a>
      </div>
  </div>
</div>
<!--subnav-->
<div class="pad-lr-10">
  <form name="myform" id="myform" action="__URL__/deleteAll" method="GET">
    <div class="table-list">
	    <table width="100%" cellspacing="0">
	      <thead>
	        <tr>
	          <th align="center" width="120" >日期</th>
	          <th align="center" >星期</th>
	          <th align="center" >新客户(人)</th>
	          <!-- <th align="center" >更新客户(人) </th>
	          			  <th align="center" ><span class="green">有效通话</span> </th>
	          			  <th align="center" ><span class="red">无效通话</span> </th> -->
	          <th align="center" >操作</th>
	        </tr>
	      </thead>
	      <tbody  id="list">
	      <volist name="list" id="vo">
	      	<tr class="callList">
	           <td align="center" >{$vo.day}</td>
	           <td align="center" >{$vo.week}</td>
	           <td align="center" class="clientNum" >{$vo.clientNum}</td>
	           <!-- <td align="center" >{$vo.clientNum2}</td>
	           <td align="center" >{$vo.youxiao}</td>
	           <td align="center" >{$vo.wuxiao}</td> -->
	           <td align="center" >
	            <a href="javascript:openWinBox('__URL__/clientList/createTime/{$vo.time}','客户列表','','',null)" >【客户列表】</a>
	            <!-- <a href="javascript:openWinBox('__URL__/recordList/talktime/{$vo.time}','电话列表')" >【电话列表】</a> -->
	           </td>
	        </tr>
	      </volist>
	      <tr>
	           <td align="center" >总量：</td>
	           <td align="center" ></td>
	           <td align="center" >{$newConsumerTotal}</td>
	           <td align="center" > </td>
	        </tr>
	      </tbody>
	    </table>
     </div>
    <div class="btn">
    	<span style="margin-right:10px; color:#000">说明：</span> 新客户是以添加新客户时的时间的统计，单位为（人）；电话量是以添加电话内容时所选择的通话时间的统计，单位为（个）。
    </div>
  </form>
</div>

</body>
</html>
<script type="text/javascript" src="__PUBLIC__/Js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
$(function(){
	//赋予状态颜色
	$('.tjbg:odd').css("background-color", "#F4F4F8");
	$('.tjbg:even').css("background-color", "#EFF1F1");

	//合计
	
	$('#myform').ajaxForm({
		beforeSubmit:  checkForm,
		success:       complete,
		dataType: 'json'
	});
	function checkForm(){
		var len = $("input[name='spaceid[]']:checked").length;
		if(len < 1){
			msg('请先选择删除项！','warning',3);
			return false;
		}
	}

	var origin = $.artDialog.open.origin;
	function complete(data){
		msg(data.info,data.data);
		if(data.status) setTimeout(function(){origin.location.reload();},1500);
	}


	var searchType = "{$Think.get.searchType}";
	if(searchType==10){
		$("#searchTime").show();
	}else{
		$("#searchTime").hide();
	}
	$("#searchType").change(function(){
		var searchType = $(this).val();
		if(searchType==10){
			$("#searchTime").show();
			return false;
		}
		searchForm.submit();
	})

	var startTime = "{$Think.get.startTime}";
	var endTime = "{$Think.get.endTime}";
	if(startTime!=''){
		$("#startTime").val(startTime);
	}
	if(endTime!=''){
		$("#endTime").val(endTime);
	}


})

function exportExcel(){
	var box = $("input[name='idArr[]']:checked");
		len = box.length,
		idArr = "";
	for (var i = 0; i < box.length; i++){
		idArr += box[i].value + ",";
	}
	location.href="__APP__/Excel/exportExcel/idArr/"+idArr;
}

//修改状态
function changeStatus(id){
	var statusId = $("#status-"+id).attr('name');
	$.get("__URL__/changeStatus/id/"+id+"/statusId/"+statusId, function(data) {
	if(statusId==1){
			$("#status-"+id).text('禁用');
			$("#status-"+id).attr('name',0);
			$("#status-"+id).attr('class','red');
		}else{
			$("#status-"+id).text('启用');
			$("#status-"+id).attr('name',1);
			$("#status-"+id).attr('class','blue');
		}
	});
}

function checkForm(){
	var searchType = $("#searchType").val();
	var startTime = $("#startTime").val();
	var endTime = $("#endTime").val();
	var d1 = parseInt(new Date(startTime).getTime()/1000/60/60/24);
	var d2 = parseInt(new Date(endTime).getTime()/1000/60/60/24);
	if(searchType==10){
		if(startTime==''){
			msg('请选择搜索时间！','warning',2);
			return false;
		}
		if(startTime>endTime && endTime!=''){
			msg('开始时间不能大于结束时间！','warning',2);
			return false;
		}

		if(d2-d1>60){
			msg('一次最多只能查询两个月的统计！','warning',2);
			return false;
		}
	}
	return true;
}
</script>